<?php
/////////////////////////////////////////////////////////////////////////////
// 这个文件是 网城创想多用户商城 项目的一部分
//
// Copyright (c) 2007 - 2008 www.shopnc.net 
//
// 要查看完整的版权信息和许可信息，请查看源代码中附带的 COPYRIGHT 文件，
// 或者访问 http://www.shopnc.net/ 获得详细信息。
/////////////////////////////////////////////////////////////////////////////

/**
 * FILE_NAME : shop.manage.php   FILE_PATH : D:\webroot\mulitishop\system\shop.manage.php
 * ....管理员商铺管理
 *
 * @copyright Copyright (c) 2007 - 2007 www.shopnc.net 
 * @author 网城创想多用户商城开发团队 php_netproject@yahoo.com.cn
 * @package 
 * @subpackage 
 * @version Mon Sep 17 12:17:10 CST 2007
 */

require_once("../global.inc.php");

class SysShopManage extends SystemFrameWork{
	/**
	 * 商铺对象
	 *
	 * @var obj
	 */
	var $obj_shop;
	/**
	 * 商铺分类对象
	 *
	 * @var obj
	 */
	var $obj_shopcategory;
	/**
	 * 分页对象
	 *
	 * @var obj
	 */
	var $obj_page;
	
	function main(){
		/**
		 * 创建商铺对象
		 */
		if (!is_object($this->obj_shop)){
			require_once("shop.class.php");
			$this->obj_shop = new ShopClass();
		}
		/**
		 * 创建商铺分类对象
		 */
		if (!is_object($this->obj_shopcategory)){
			require_once("shopcategory.class.php");
			$this->obj_shopcategory = new ShopCategoryClass();
		}
		/**
		 * 创建分页对象
		 */
		if (!is_object($this->obj_page)){
			require_once("commonpage.class.php");
			$this->obj_page = new CommonPage();
		}
		
		/**
		 * 设置模板路径
		 */
		$this->setsubtemplates("system");
		
		/**
		 * 语言包
		 */
		$this->getlang("shop");
		
		/**
		 * 根据参数调用相应的方法
		 */
		switch ($this->_input['action']){
			case "show":
				$this->_showShop();
				break;
			case "check":
				$this->_checkShop();
				break;
			default:
				$this->_getShopList();
		}
		
	}
	
	/**
	 * 得到商铺列表
	 *
	 */
	function _getShopList(){
		/**
		 * 获取商铺的2级分类
		 */
	    $category_array = $this->obj_shopcategory->getLevelCategory(2,0);
	    $category_array = Common::getSelectArray($category_array,array('class_id','class_name'));
	    /**
	     * 将商铺分类以下拉框的形式出现
	     */
	    $select_category = Common::showForm_Select("slcShopClass","","",$category_array,$this->_input["slcShopClass"],array('value'=>"",'text'=>'请选择商铺分类'));
	    
	    $this->obj_page->pagebarnum(20);    //每页20条记录
	    
	    $shop_array = $this->obj_shop->getShopList($this->_input,$this->obj_page);
	    
	    foreach ($shop_array as $k=>$v){
	    	$shop_array[$k]['class_name'] = $category_array[$v['shop_class']];
	    	$shop_array[$k]['open_state'] = $this->_b_config['checkstate'][$v['ischeck']];
	    }
	    
	    //print_r($shop_array);
	    $pagelist = $this->obj_page->show(1);      //分页显示
	    
	    $this->output("shop_text_salerange", $this->_input["txtSaleRange"]);    //输出商铺经营范围
	    $this->output("shop_text_shopname", $this->_input["txtShopName"]);    //输出商铺名称
		$this->output("shop_select_category", $select_category);    //输出商铺分类以下拉框
		$this->output("shop_array", $shop_array);    //输出商铺列表
		$this->output("shop_page", $pagelist);    //输出商铺分页
		$this->showpage("sys_shop.manage");
	}
	
	/**
	 * 查看某一商铺信息
	 *
	 */
	function _showShop(){
		/**
		 * 获取商铺的2级分类
		 */
	    $category_array = $this->obj_shopcategory->getLevelCategory(2,0);
	    $category_array = Common::getSelectArray($category_array,array('class_id','class_name'));
	    
	    $shop_array = $this->obj_shop->getOneShop($this->_input['shopid']);
	    $shop_array['class_name'] = $category_array[$shop_array['shop_class']];
	    $shop_array['open_state'] = $this->_b_config['checkstate'][$shop_array['ischeck']];
	    
	    $this->output("shop_array", $shop_array);    //输出商铺信息
	    $this->showpage("sys_shop.show");
	}
	
	/**
	 * 审核商铺
	 *
	 */
	function _checkShop(){
		$this->obj_shop->checkShop($this->_input['shopid'],$this->_input['check']);
	}
}

$shop_manage = new SysShopManage();
$shop_manage->main();
unset($shop_manage);
?>